package main

import (
	"fmt"

	"leecode/tree"
)

var maxDepth int

func main() {
	root := &tree.Node{
		Val: 3,
		Left: &tree.Node{
			Val: 9,
		},
		Right: &tree.Node{
			Val: 20,
			Left: &tree.Node{
				Val: 15,
			},
			Right: &tree.Node{
				Val: 7,
			},
		},
	}

	// v := DfsMLR(root, 1)
	// fmt.Println("=====================")
	// fmt.Println(v)
	dec(root)
}

func DfsMLR(root *tree.Node, depth int) int {
	if root == nil {
		return maxDepth
	}
	root.Depth = depth

	if root.Depth > maxDepth {
		maxDepth = root.Depth
	}
	DfsMLR(root.Left, root.Depth+1)
	fmt.Println(root.Val)
	DfsMLR(root.Right, root.Depth+1)

	return maxDepth
}

func dec(root *tree.Node) {
	if root == nil {
		return
	}
	

	dec(root.Left)
	fmt.Println(root.Val)
	dec(root.Right)
}
